package org.freespace.controller;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.freespace.model.Testplan;
import org.freespace.service.ITestplanService;
import org.freespace.utils.response.CommonResult;
import org.freespace.vo.TestPlanVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Random;

/**
 * <p>
 * 用来做性能测试的接口
 * </p>
 *
 * @author liuqi
 * @since 2023-06-19
 */
@Slf4j
@RestController
@RequestMapping("/testapi")
public class TestApiController {

    @Autowired
    ITestplanService testplanService;

    @GetMapping(value = "api1")
    public CommonResult api1() {
        int i = new Random().nextInt(1000);
        try {
            Thread.sleep(i);
            if (i%2 == 0) {
                return CommonResult.failed();
            }
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        return CommonResult.success();
    }

    @GetMapping(value = "api2")
    public CommonResult api2() {
        int i = new Random().nextInt(1000);
        try {
            Thread.sleep(i);
            if (i%2 == 0) {
                return CommonResult.failed();
            }
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        return CommonResult.success();
    }

}
